package view;

import util.EventoBotoes;
import util.ViewUtil;
import java.awt.event.KeyEvent;
import model.Cargo;
import util.UrnaUtil;

public class CadastroCargo extends javax.swing.JDialog {

  Cargo CargoModel;

  public CadastroCargo(java.awt.Frame parent, boolean modal) {

    super(parent, modal);
    setTitle("Cadastro de Cargos");
    initComponents();
    setLocationRelativeTo(null);
    EventoBotoes.inicio(jPanelBotoes.getComponents(), jPanelStatus.getComponents());
    ViewUtil.trocaPanels(jPanelMeio, jPanelConsulta);

  }

  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    jPanelCampos = new javax.swing.JPanel();
    jLabelNomeCargo = new javax.swing.JLabel();
    jTextFieldNomeCargo = new javax.swing.JTextField();
    jLabel1 = new javax.swing.JLabel();
    edtQtdeDigito = new javax.swing.JFormattedTextField();
    jPanel1 = new javax.swing.JPanel();
    jRadioButtonSuplente = new javax.swing.JRadioButton();
    jRadioButtonVice = new javax.swing.JRadioButton();
    jRadioButtonSemViceSuplente = new javax.swing.JRadioButton();
    jPanelConsulta = new javax.swing.JPanel();
    jLabelFiltro = new javax.swing.JLabel();
    jComboBoxListaFiltro = new javax.swing.JComboBox();
    jLabelValorPesquisa = new javax.swing.JLabel();
    jTextFieldInformacaoPesquisa = new javax.swing.JTextField();
    buttonGroup = new javax.swing.ButtonGroup();
    jPanelBotoes = new javax.swing.JPanel();
    jButtonConsultar = new javax.swing.JButton();
    jButtonNovo = new javax.swing.JButton();
    jButtonEditar = new javax.swing.JButton();
    jButtonExcluir = new javax.swing.JButton();
    jButtonGravar = new javax.swing.JButton();
    jButtonCancelar = new javax.swing.JButton();
    jPanelMeio = new javax.swing.JPanel();
    jPanelStatus = new javax.swing.JPanel();
    jLabelStatus = new javax.swing.JLabel();
    jLabelGravacao = new javax.swing.JLabel();

    jPanelCampos.setBackground(new java.awt.Color(9, 51, 51));
    jPanelCampos.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

    jLabelNomeCargo.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
    jLabelNomeCargo.setForeground(new java.awt.Color(255, 255, 255));
    jLabelNomeCargo.setText("Nome do Cargo");
    jPanelCampos.add(jLabelNomeCargo, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 11, -1, -1));

    jTextFieldNomeCargo.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
    jTextFieldNomeCargo.setBorder(null);
    jPanelCampos.add(jTextFieldNomeCargo, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 40, 380, 30));

    jLabel1.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
    jLabel1.setForeground(new java.awt.Color(255, 255, 255));
    jLabel1.setText("Quantidade de Dígitos");
    jPanelCampos.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 80, -1, 20));

    edtQtdeDigito.setBorder(null);
    try {
      edtQtdeDigito.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("#")));
    } catch (java.text.ParseException ex) {
      ex.printStackTrace();
    }
    edtQtdeDigito.setHorizontalAlignment(javax.swing.JTextField.CENTER);
    edtQtdeDigito.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
    jPanelCampos.add(edtQtdeDigito, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 110, 40, 30));

    jPanel1.setBackground(new java.awt.Color(0, 51, 51));
    jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204)), "Opções para Vice e Suplentes", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Segoe UI", 0, 12), new java.awt.Color(255, 255, 255))); // NOI18N
    jPanel1.setForeground(new java.awt.Color(255, 255, 255));

    jRadioButtonSuplente.setBackground(new java.awt.Color(0, 51, 51));
    buttonGroup.add(jRadioButtonSuplente);
    jRadioButtonSuplente.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
    jRadioButtonSuplente.setForeground(new java.awt.Color(255, 255, 255));
    jRadioButtonSuplente.setText("Suplente");

    jRadioButtonVice.setBackground(new java.awt.Color(0, 51, 51));
    buttonGroup.add(jRadioButtonVice);
    jRadioButtonVice.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
    jRadioButtonVice.setForeground(new java.awt.Color(255, 255, 255));
    jRadioButtonVice.setText("Vice");

    jRadioButtonSemViceSuplente.setBackground(new java.awt.Color(0, 51, 51));
    buttonGroup.add(jRadioButtonSemViceSuplente);
    jRadioButtonSemViceSuplente.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
    jRadioButtonSemViceSuplente.setForeground(new java.awt.Color(255, 255, 255));
    jRadioButtonSemViceSuplente.setText("Sem Vice e Suplente");

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
      jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel1Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(jRadioButtonSemViceSuplente)
          .addComponent(jRadioButtonSuplente)
          .addComponent(jRadioButtonVice))
        .addContainerGap(233, Short.MAX_VALUE))
    );
    jPanel1Layout.setVerticalGroup(
      jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel1Layout.createSequentialGroup()
        .addContainerGap()
        .addComponent(jRadioButtonSemViceSuplente)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addComponent(jRadioButtonVice)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
        .addComponent(jRadioButtonSuplente)
        .addContainerGap(18, Short.MAX_VALUE))
    );

    jPanelCampos.add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 150, 380, -1));

    jPanelConsulta.setBackground(new java.awt.Color(0, 51, 51));
    jPanelConsulta.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

    jLabelFiltro.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
    jLabelFiltro.setForeground(new java.awt.Color(255, 255, 255));
    jLabelFiltro.setText("Filtro");
    jPanelConsulta.add(jLabelFiltro, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 14, -1, 20));

    jComboBoxListaFiltro.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
    jComboBoxListaFiltro.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Nome" }));
    jComboBoxListaFiltro.setToolTipText("");
    jComboBoxListaFiltro.setBorder(null);
    jPanelConsulta.add(jComboBoxListaFiltro, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 10, 140, 30));
    jComboBoxListaFiltro.getAccessibleContext().setAccessibleName("");

    jLabelValorPesquisa.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
    jLabelValorPesquisa.setForeground(new java.awt.Color(255, 255, 255));
    jLabelValorPesquisa.setText("Valor");
    jPanelConsulta.add(jLabelValorPesquisa, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 55, -1, -1));

    jTextFieldInformacaoPesquisa.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
    jTextFieldInformacaoPesquisa.setBorder(null);
    jTextFieldInformacaoPesquisa.addKeyListener(new java.awt.event.KeyAdapter() {
      public void keyPressed(java.awt.event.KeyEvent evt) {
        jTextFieldInformacaoPesquisaKeyPressed(evt);
      }
    });
    jPanelConsulta.add(jTextFieldInformacaoPesquisa, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 50, 350, 30));

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setMinimumSize(new java.awt.Dimension(800, 550));
    setPreferredSize(new java.awt.Dimension(800, 550));
    setResizable(false);

    jPanelBotoes.setBackground(new java.awt.Color(0, 51, 51));
    jPanelBotoes.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 0, 1, 0, new java.awt.Color(255, 255, 255)));
    jPanelBotoes.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 10, 10));

    jButtonConsultar.setBackground(new java.awt.Color(0, 153, 204));
    jButtonConsultar.setForeground(new java.awt.Color(255, 255, 255));
    jButtonConsultar.setText("Consultar");
    jButtonConsultar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
    jButtonConsultar.setMaximumSize(new java.awt.Dimension(100, 30));
    jButtonConsultar.setMinimumSize(new java.awt.Dimension(100, 30));
    jButtonConsultar.setPreferredSize(new java.awt.Dimension(100, 30));
    jButtonConsultar.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButtonConsultarActionPerformed(evt);
      }
    });
    jPanelBotoes.add(jButtonConsultar);

    jButtonNovo.setBackground(new java.awt.Color(0, 153, 204));
    jButtonNovo.setForeground(new java.awt.Color(255, 255, 255));
    jButtonNovo.setText("Novo");
    jButtonNovo.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
    jButtonNovo.setMaximumSize(new java.awt.Dimension(100, 30));
    jButtonNovo.setMinimumSize(new java.awt.Dimension(100, 30));
    jButtonNovo.setPreferredSize(new java.awt.Dimension(100, 30));
    jButtonNovo.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButtonNovoActionPerformed(evt);
      }
    });
    jPanelBotoes.add(jButtonNovo);

    jButtonEditar.setBackground(new java.awt.Color(0, 153, 204));
    jButtonEditar.setForeground(new java.awt.Color(255, 255, 255));
    jButtonEditar.setText("Editar");
    jButtonEditar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
    jButtonEditar.setMaximumSize(new java.awt.Dimension(100, 30));
    jButtonEditar.setMinimumSize(new java.awt.Dimension(100, 30));
    jButtonEditar.setPreferredSize(new java.awt.Dimension(100, 30));
    jButtonEditar.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButtonEditarActionPerformed(evt);
      }
    });
    jPanelBotoes.add(jButtonEditar);

    jButtonExcluir.setBackground(new java.awt.Color(0, 153, 204));
    jButtonExcluir.setForeground(new java.awt.Color(255, 255, 255));
    jButtonExcluir.setText("Excluir");
    jButtonExcluir.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
    jButtonExcluir.setMaximumSize(new java.awt.Dimension(100, 30));
    jButtonExcluir.setMinimumSize(new java.awt.Dimension(100, 30));
    jButtonExcluir.setPreferredSize(new java.awt.Dimension(100, 30));
    jButtonExcluir.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButtonExcluirActionPerformed(evt);
      }
    });
    jPanelBotoes.add(jButtonExcluir);

    jButtonGravar.setBackground(new java.awt.Color(0, 153, 204));
    jButtonGravar.setForeground(new java.awt.Color(255, 255, 255));
    jButtonGravar.setText("Gravar");
    jButtonGravar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
    jButtonGravar.setMaximumSize(new java.awt.Dimension(100, 30));
    jButtonGravar.setMinimumSize(new java.awt.Dimension(100, 30));
    jButtonGravar.setPreferredSize(new java.awt.Dimension(100, 30));
    jButtonGravar.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButtonGravarActionPerformed(evt);
      }
    });
    jPanelBotoes.add(jButtonGravar);

    jButtonCancelar.setBackground(new java.awt.Color(0, 153, 204));
    jButtonCancelar.setForeground(new java.awt.Color(255, 255, 255));
    jButtonCancelar.setText("Cancelar");
    jButtonCancelar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255)));
    jButtonCancelar.setMaximumSize(new java.awt.Dimension(100, 30));
    jButtonCancelar.setMinimumSize(new java.awt.Dimension(100, 30));
    jButtonCancelar.setPreferredSize(new java.awt.Dimension(100, 30));
    jButtonCancelar.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        jButtonCancelarActionPerformed(evt);
      }
    });
    jPanelBotoes.add(jButtonCancelar);

    getContentPane().add(jPanelBotoes, java.awt.BorderLayout.NORTH);

    jPanelMeio.setBackground(new java.awt.Color(0, 51, 51));

    javax.swing.GroupLayout jPanelMeioLayout = new javax.swing.GroupLayout(jPanelMeio);
    jPanelMeio.setLayout(jPanelMeioLayout);
    jPanelMeioLayout.setHorizontalGroup(
      jPanelMeioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 688, Short.MAX_VALUE)
    );
    jPanelMeioLayout.setVerticalGroup(
      jPanelMeioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 310, Short.MAX_VALUE)
    );

    getContentPane().add(jPanelMeio, java.awt.BorderLayout.CENTER);

    jPanelStatus.setBackground(new java.awt.Color(0, 51, 51));
    jPanelStatus.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 0, 0, 0, new java.awt.Color(255, 255, 255)));
    jPanelStatus.setMinimumSize(new java.awt.Dimension(30, 30));
    jPanelStatus.setPreferredSize(new java.awt.Dimension(30, 30));
    jPanelStatus.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 10, 0));

    jLabelStatus.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
    jLabelStatus.setForeground(new java.awt.Color(255, 51, 51));
    jLabelStatus.setMaximumSize(new java.awt.Dimension(100, 30));
    jLabelStatus.setMinimumSize(new java.awt.Dimension(100, 30));
    jLabelStatus.setPreferredSize(new java.awt.Dimension(100, 30));
    jPanelStatus.add(jLabelStatus);

    jLabelGravacao.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N
    jLabelGravacao.setForeground(new java.awt.Color(255, 255, 255));
    jLabelGravacao.setMaximumSize(new java.awt.Dimension(300, 30));
    jLabelGravacao.setMinimumSize(new java.awt.Dimension(300, 30));
    jLabelGravacao.setPreferredSize(new java.awt.Dimension(300, 30));
    jPanelStatus.add(jLabelGravacao);

    getContentPane().add(jPanelStatus, java.awt.BorderLayout.SOUTH);

    pack();
  }// </editor-fold>//GEN-END:initComponents

    private void jButtonConsultarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonConsultarActionPerformed

      EventoBotoes.inicio(jPanelBotoes.getComponents(), jPanelStatus.getComponents());
      ViewUtil.trocaPanels(jPanelMeio, jPanelConsulta);
      limpaCampos();

    }//GEN-LAST:event_jButtonConsultarActionPerformed

    private void jButtonNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNovoActionPerformed

      EventoBotoes.editando(jPanelBotoes.getComponents(), jPanelStatus.getComponents(), jPanelCampos.getComponents(), "N", true);
      ViewUtil.trocaPanels(jPanelMeio, jPanelCampos);
      limpaCampos();

    }//GEN-LAST:event_jButtonNovoActionPerformed

    private void jButtonEditarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonEditarActionPerformed

      EventoBotoes.editando(jPanelBotoes.getComponents(), jPanelStatus.getComponents(), jPanelCampos.getComponents(), "E", true);

    }//GEN-LAST:event_jButtonEditarActionPerformed

    private void jButtonExcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonExcluirActionPerformed
      if (UrnaUtil.confirmDialog("Deseja excluir esse registro?", "Atenção")) {
        Cargo.deletar(jTextFieldNomeCargo.getText());
        EventoBotoes.inicio(jPanelBotoes.getComponents(), jPanelStatus.getComponents());
        ViewUtil.trocaPanels(jPanelMeio, jPanelConsulta);
        jLabelGravacao.setText("Registro excluído com sucesso !");
        limpaCampos();
      }

    }//GEN-LAST:event_jButtonExcluirActionPerformed

    private void jButtonGravarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGravarActionPerformed

      Cargo cargo = new Cargo();
      
      if (ViewUtil.isEmpty(jPanelCampos.getComponents())) {
        if (validaDigito(edtQtdeDigito.getText())) {
          if(!(Integer.parseInt(edtQtdeDigito.getText()) < 0)) {
            
            cargo.setNome(jTextFieldNomeCargo.getText());
            cargo.setQntdDigitos(Integer.parseInt(edtQtdeDigito.getText()));
            cargo.setPossuiVice(jRadioButtonVice.isSelected());
            cargo.setPossuiSuplentes(jRadioButtonSuplente.isSelected());
            
            switch (jLabelStatus.getText()) {
              case "Inserindo":
                Cargo.inserir(cargo);
                break;
              case "Editando":
                Cargo.editar(CargoModel, cargo);
                break;
            }
            EventoBotoes.inicio(jPanelBotoes.getComponents(), jPanelStatus.getComponents());
            ViewUtil.trocaPanels(jPanelMeio, jPanelConsulta);
            jLabelGravacao.setText("");
            limpaCampos();
          } else {
            jLabelGravacao.setText("Número de cadidato incorreto !");
          }
        } else {
          jLabelGravacao.setText("A Quantidade de dígitos deve ser entre 2 e 5 !");
        }
      } else {
        jLabelGravacao.setText("Preencha todos os campos !");
      }
    }//GEN-LAST:event_jButtonGravarActionPerformed

    private void jButtonCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelarActionPerformed

      if (UrnaUtil.confirmDialog("Deseja cancelar essa transação?", "Atenção")) {

        EventoBotoes.inicio(jPanelBotoes.getComponents(), jPanelStatus.getComponents());
        ViewUtil.trocaPanels(jPanelMeio, jPanelConsulta);
        jLabelGravacao.setText("");
        limpaCampos();
      }
    }//GEN-LAST:event_jButtonCancelarActionPerformed

    private void jTextFieldInformacaoPesquisaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldInformacaoPesquisaKeyPressed

      if (evt.getKeyCode() == KeyEvent.VK_ENTER) {

        if (Cargo.consultar(jTextFieldInformacaoPesquisa.getText()) == null) {
          jLabelGravacao.setText("Cargo não existe !");
        } else {
          ViewUtil.trocaPanels(jPanelMeio, jPanelCampos);
          EventoBotoes.consultando(jPanelBotoes.getComponents(), jPanelStatus.getComponents(), jPanelCampos.getComponents());
          CargoModel = Cargo.consultar(jTextFieldInformacaoPesquisa.getText());
          jTextFieldNomeCargo.setText(CargoModel.getNome());
          edtQtdeDigito.setText(String.format("%s", CargoModel.getQntdDigitos()));
          if (CargoModel.isPossuiVice()) {
            buttonGroup.setSelected(jRadioButtonVice.getModel(), true);
          } else if (CargoModel.isPossuiSuplentes()) {
            buttonGroup.setSelected(jRadioButtonSuplente.getModel(), true);
          } else {
            buttonGroup.setSelected(jRadioButtonSemViceSuplente.getModel(), true);
          }
        }
      } else {
        jLabelGravacao.setText("");
      }
    }//GEN-LAST:event_jTextFieldInformacaoPesquisaKeyPressed

  public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
      public void run() {
        CadastroCargo dialog = new CadastroCargo(new javax.swing.JFrame(), true);
        dialog.addWindowListener(new java.awt.event.WindowAdapter() {
          @Override
          public void windowClosing(java.awt.event.WindowEvent e) {
            System.exit(0);
          }
        });
        dialog.setVisible(true);
      }
    });
  }

  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.ButtonGroup buttonGroup;
  private javax.swing.JFormattedTextField edtQtdeDigito;
  private javax.swing.JButton jButtonCancelar;
  private javax.swing.JButton jButtonConsultar;
  private javax.swing.JButton jButtonEditar;
  private javax.swing.JButton jButtonExcluir;
  private javax.swing.JButton jButtonGravar;
  private javax.swing.JButton jButtonNovo;
  private javax.swing.JComboBox jComboBoxListaFiltro;
  private javax.swing.JLabel jLabel1;
  private javax.swing.JLabel jLabelFiltro;
  private javax.swing.JLabel jLabelGravacao;
  private javax.swing.JLabel jLabelNomeCargo;
  private javax.swing.JLabel jLabelStatus;
  private javax.swing.JLabel jLabelValorPesquisa;
  private javax.swing.JPanel jPanel1;
  private javax.swing.JPanel jPanelBotoes;
  private javax.swing.JPanel jPanelCampos;
  private javax.swing.JPanel jPanelConsulta;
  private javax.swing.JPanel jPanelMeio;
  private javax.swing.JPanel jPanelStatus;
  private javax.swing.JRadioButton jRadioButtonSemViceSuplente;
  private javax.swing.JRadioButton jRadioButtonSuplente;
  private javax.swing.JRadioButton jRadioButtonVice;
  private javax.swing.JTextField jTextFieldInformacaoPesquisa;
  private javax.swing.JTextField jTextFieldNomeCargo;
  // End of variables declaration//GEN-END:variables

  private void limpaCampos() {
    jTextFieldInformacaoPesquisa.setText("");
    jTextFieldNomeCargo.setText("");
    edtQtdeDigito.setText("");
    //jRadioButtonSemViceSuplente.setSelected(false);
    //jRadioButtonVice.setSelected(false);
    //jRadioButtonSuplente.setSelected(false);
    buttonGroup.setSelected(null, true);
  }

  private boolean validaDigito(String num) {

    int nume = Integer.parseInt(num);

    if (nume < 2 || nume > 5) {
      return false;
    } else {
      return true;
    }
  }
}
